<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">入职申请详情</block>
		</cu-custom>
		<form>
			<view class="cu-form-group">
				<view class="title">公司</view>
				<my-select range-key="text" value-key="value" dict-code="crm_company,name,id"
					v-model="myFormData.company" />
			</view>
			<view class="cu-form-group">
				<view class="title">身份类别</view>
				<my-select range-key="text" value-key="value" dict-code="identity_category"
					v-model="myFormData.identityCategory" />
			</view>
			<view class="cu-form-group">
				<view class="title">头像</view>
				<view class="grid col-4 grid-square flex-sub">
					<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
						:data-url="imgList[index]">
						<image :src="imgList[index]" mode="aspectFill"></image>
						<view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index">
							<text class='cuIcon-close'></text>
						</view>
					</view>
					<view class="solids" @tap="ChooseImage" v-if="imgList.length<1">
						<text class='cuIcon-cameraadd'></text>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">姓名</view>
				<input placeholder="请输入姓名" name="input" v-model="myFormData.realname"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">性别</view>
				<switch class='switch-sex' @change="SwitchC" :class="switchC?'checked':''"
					:checked="switchC?true:false"></switch>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证号码</view>
				<input placeholder="输入身份证号码" name="input" v-model="myFormData.idCard"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证签发机关</view>
				<input placeholder="输入身份证签发机关" name="input" v-model="myFormData.idCardIssue"></input>
				<text class='cuIcon-locationfill text-orange'></text>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证地址</view>
				<input placeholder="输入身份证地址" name="input" v-model="myFormData.idCardAddress"></input>
				<text class='cuIcon-locationfill text-orange'></text>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证有效期限</view>
				<picker mode="date" :value="idCardValidPeriod" @change="DateChangeIdCardValidPeriod">
					<view class="picker">
						{{idCardValidPeriod}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证开始时间</view>
				<picker mode="date" :value="idCardStartTime" @change="DateChangeIdCardStartTime">
					<view class="picker">
						{{idCardStartTime}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">出生日期</view>
				<picker mode="date" :value="birthday" @change="DateChangeBirthday">
					<view class="picker">
						{{birthday}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">民族</view>
				<input placeholder="输入民族" name="input" v-model="myFormData.nation"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">籍贯</view>
				<input placeholder="输入籍贯" name="input" v-model="myFormData.nativePlace"></input>
				<text class='cuIcon-locationfill text-orange'></text>
			</view>
			<view class="cu-form-group">
				<view class="title">邮箱</view>
				<input placeholder="输入邮箱" name="input" v-model="myFormData.email"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">手机号码</view>
				<input placeholder="输入手机号码" name="input" v-model="myFormData.phone"></input>
				<view class="cu-capsule radius">
					<view class='cu-tag bg-blue '>
						+86
					</view>
					<view class="cu-tag line-blue">
						中国大陆
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">婚否</view>
				<my-select range-key="text" value-key="value" dict-code="marital_status"
					v-model="myFormData.maritalStatus" />
			</view>
			<view class="cu-form-group">
				<view class="title">身高</view>
				<input placeholder="输入身高" name="input" type="number" v-model="myFormData.height"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">党团员</view>
				<my-select range-key="text" value-key="value" dict-code="party_and_league_members"
					v-model="myFormData.partyAndLeagueMembers" />
			</view>
			<view class="cu-form-group">
				<view class="title">职称</view>
				<input placeholder="输入职称" name="input" v-model="myFormData.title"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">首次工作时间</view>
				<picker mode="date" :value="firstTimeWorking" @change="DateChangeFirstTimeWorking">
					<view class="picker">
						{{firstTimeWorking}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">学历</view>
				<my-select range-key="text" value-key="value" dict-code="education" v-model="myFormData.education" />
			</view>
			<view class="cu-form-group">
				<view class="title">毕业时间</view>
				<picker mode="date" :value="graduationTime" @change="DateChangeGraduationTime">
					<view class="picker">
						{{graduationTime}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">毕业院校</view>
				<input placeholder="输入毕业院校" name="input" v-model="myFormData.graduationInstitution"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">现居住地址</view>
				<input placeholder="输入现居住地址" name="input" v-model="myFormData.currentAddress"></input>
				<text class='cuIcon-locationfill text-orange'></text>
			</view>
			<view class="cu-form-group">
				<view class="title">紧急联系人</view>
				<input placeholder="输入紧急联系人" name="input" v-model="myFormData.emergencyContact"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">紧急联系人电话</view>
				<input placeholder="输入紧急联系人电话" name="input" v-model="myFormData.emergencyContactPhone"></input>
				<view class="cu-capsule radius">
					<view class='cu-tag bg-blue '>
						+86
					</view>
					<view class="cu-tag line-blue">
						中国大陆
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">身份证复印件</view>
				<view class="grid col-4 grid-square flex-sub">
					<view class="bg-img" v-for="(item,index) in imgListIdCardCopy" :key="index" @tap="ViewImage"
						:data-url="imgListIdCardCopy[index]">
						<image :src="imgListIdCardCopy[index]" mode="aspectFill"></image>
						<view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index">
							<text class='cuIcon-close'></text>
						</view>
					</view>
					<view class="solids" @tap="ChooseImageIdCardCopy" v-if="imgListIdCardCopy.length<1">
						<text class='cuIcon-cameraadd'></text>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">职务</view>
				<my-select range-key="text" value-key="value" dict-code="sys_position,name,code"
					v-model="myFormData.post" />
			</view>
			<view class="cu-form-group">
				<view class="title">部门</view>
				<text>{{myFormData.departTitle}}</text>
				<view class="cu-capsule radius">
					<view class="cu-tag line-blue" @tap="ChooseDepartIds">
						选择部门
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">关联定岗定编</view>
				<input placeholder="输入关联定岗定编" name="input" v-model="myFormData.relatedJobAllocation"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">关联定岗定编文本</view>
				<input placeholder="输入关联定岗定编文本" name="input" v-model="myFormData.relatedJobAllocationTxt"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">熟练度</view>
				<my-select range-key="text" value-key="value" dict-code="proficiency"
					v-model="myFormData.proficiency" />
			</view>
			<view class="cu-form-group">
				<view class="title">特长</view>
				<input placeholder="输入特长" name="input" v-model="myFormData.speciality"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">拟入职时间</view>
				<picker mode="date" :value="proposedEmploymentDate" @change="DateChangeProposedEmploymentDate">
					<view class="picker">
						{{proposedEmploymentDate}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">试用期开始时间</view>
				<picker mode="date" :value="probationPeriodStartTime" @change="DateChangeProbationPeriodStartTime">
					<view class="picker">
						{{probationPeriodStartTime}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">转正日期</view>
				<picker mode="date" :value="regularDate" @change="DateChangeRegularDate">
					<view class="picker">
						{{regularDate}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">试用期时长</view>
				<input placeholder="输入试用期时长" name="input" type="number"
					v-model="myFormData.probationPeriodDuration"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">是否已在三天内报道</view>
				<my-select range-key="text" value-key="value" dict-code="yn"
					v-model="myFormData.reportedWithinThreeDays" />
			</view>
			<view class="cu-form-group">
				<view class="title">试用工资</view>
				<input placeholder="输入试用工资" name="input" type="number" v-model="myFormData.probationSalary"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">转正工资</view>
				<input placeholder="输入转正工资" name="input" type="number" v-model="myFormData.regularSalary"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">当前工资</view>
				<input placeholder="输入当前工资" name="input" type="number" v-model="myFormData.currentSalary"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">住宿方式</view>
				<my-select range-key="text" value-key="value" dict-code="accommodation_methods"
					v-model="myFormData.accommodationMethods" />
			</view>
			<view class="cu-form-group">
				<view class="title">工号</view>
				<input placeholder="输入工号" name="input" v-model="myFormData.workNo"></input>
			</view>
			<!-- 家庭成员 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 家庭成员
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal" data-target="familyMembers">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.familyMembers" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">

					<view class="content">
						<view class="text-grey">姓名:{{item.name}}</view>
						<view class="text-grey">与本人关系:{{item.relationship}}</view>
						<view class="text-grey">联系方式:{{item.phone}}</view>
						<view class="text-grey">工作单位:{{item.workUnit}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'familyMembers')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'familyMembers')">删除</view>
					</view>
				</view>
			</view>

			<!-- 个人简历 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 个人简历
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal" data-target="resumes">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.resumes" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
					<view class="content">
						<view class="text-grey">工作单位:{{item.workUnit}}</view>
						<view class="text-grey">职务:{{item.post}}</view>
						<view class="text-grey">开始时间:{{item.startTime}}</view>
						<view class="text-grey">结束时间:{{item.endTime}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'resumes')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'resumes')">删除</view>
					</view>
				</view>
			</view>

			<!-- 附属职务 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 附属职务
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal" data-target="subPosts">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.subPosts" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
					<view class="content">
						<view class="text-grey">公司:{{item.company}}</view>
						<view class="text-grey">部门:{{item.departTitle}}</view>
						<view class="text-grey">计费标准:{{item.freightBasis}}</view>
						<view class="text-grey">职务:{{item.post}}</view>
						<view class="text-grey">职务等级:{{item.postLevel}}</view>
						<view class="text-grey">职务类别:{{item.postType}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'subPosts')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'subPosts')">删除</view>
					</view>
				</view>
			</view>

			<!-- 荣誉证书 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 荣誉证书
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal" data-target="honors">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.honors" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
					<view class="content">
						<view class="text-grey">荣誉名称:{{item.name}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'honors')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'honors')">删除</view>
					</view>
				</view>
			</view>

			<!-- 其他事项 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 其他事项
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal" data-target="otherMatters">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.otherMatters" :key="index" @touchstart="ListTouchStart"
					@touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
					<view class="content">
						<view class="text-grey">说明:{{item.reason}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'otherMatters')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'otherMatters')">删除</view>
					</view>
				</view>
			</view>

			<!-- 本公司奖惩情况 -->
			<view class="cu-bar bg-white solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-title text-orange "></text> 本公司奖惩情况
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow" @tap="showModal"
						data-target="ourCompanyReceivesRewards">添加</button>
				</view>
			</view>
			<view class="cu-list">
				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
					v-for="(item,index) in myFormData.ourCompanyReceivesRewards" :key="index"
					@touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd"
					:data-target="'move-box-' + index">
					<view class="content">
						<view class="text-grey">离职详情：{{item.leaveReason}}</view>
						<view class="text-grey">详情：{{item.reason}}</view>
						<view class="text-grey">奖惩情况：{{item.rewards}}</view>
					</view>
					<view class="move">
						<view class="bg-grey" @tap="editData(index,'ourCompanyReceivesRewards')">编辑</view>
						<view class="bg-red" @tap="deleteData(index,'ourCompanyReceivesRewards')">删除</view>
					</view>
				</view>
			</view>

			<!-- 提交 -->
			<view class="padding flex flex-direction">
				<button class="cu-btn bg-blue lg" @click="onSubmit">提交</button>
			</view>
		</form>

		<!-- 弹窗 -->
		<!-- 家庭成员 -->
		<view class="cu-modal" :class="modalName=='familyMembers'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						家庭成员
					</view>
					<view class="cu-form-group">
						<view class="title">姓名</view>
						<input placeholder="请输入姓名" name="input" v-model="familyMembers.name"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">与本人关系</view>
						<input placeholder="请输入与本人关系" name="input" v-model="familyMembers.relationship"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">联系电话</view>
						<input placeholder="联系电话" name="input" v-model="familyMembers.phone"></input>
						<view class="cu-capsule radius">
							<view class='cu-tag bg-blue '>
								+86
							</view>
							<view class="cu-tag line-blue">
								中国大陆
							</view>
						</view>
					</view>
					<view class="cu-form-group">
						<view class="title">工作单位</view>
						<input placeholder="请输入工作单位" name="input" v-model="familyMembers.workUnit"></input>
					</view>
					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg" @click="onSubmitData('familyMembers')">提交</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 个人简历 -->
		<view class="cu-modal" :class="modalName=='resumes'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						个人简历
					</view>
					<view class="cu-form-group">
						<view class="title">工作单位</view>
						<input placeholder="请输入工作单位" name="input" v-model="resumes.workUnit"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">职务</view>
						<input placeholder="请输入职务" name="input" v-model="resumes.post"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">开始时间</view>
						<picker mode="date" :value="startTime" @change="DateChangeStartTime">
							<view class="picker">
								{{startTime}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group">
						<view class="title">结束时间</view>
						<picker mode="date" :value="endTime" @change="DateChangeEndTime">
							<view class="picker">
								{{endTime}}
							</view>
						</picker>
					</view>

					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg" @click="onSubmitData('resumes')">提交</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 附属职务 -->
		<view class="cu-modal" :class="modalName=='subPosts'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						附属职务
					</view>
					<view class="cu-form-group">
						<view class="title">公司</view>
						<my-select range-key="text" value-key="value" dict-code="crm_company,name,id"
							v-model="subPosts.company" />
					</view>
					<view class="cu-form-group">
						<view class="title">部门</view>
						<text>{{subPosts.departTitle}}</text>
						<view class="cu-capsule radius">
							<view class="cu-tag line-blue" @tap="ChooseDepartIds('subPosts')">
								选择部门
							</view>
						</view>
					</view>
					<view class="cu-form-group">
						<view class="title">计费标准</view>
						<my-select range-key="text" value-key="value" dict-code="freight_basis"
							v-model="subPosts.freightBasis" />
					</view>
					<view class="cu-form-group">
						<view class="title">职务</view>
						<my-select range-key="text" value-key="value" dict-code="sys_position,name,code"
							v-model="subPosts.post" />
					</view>
					<view class="cu-form-group">
						<view class="title">职务等级</view>
						<my-select range-key="text" value-key="value" dict-code="post_level"
							v-model="subPosts.postLevel" />
					</view>
					<view class="cu-form-group">
						<view class="title">职务类别</view>
						<my-select range-key="text" value-key="value" dict-code="post_type"
							v-model="subPosts.postType" />
					</view>

					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg" @click="onSubmitData('subPosts')">提交</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 荣誉证书 -->
		<view class="cu-modal" :class="modalName=='honors'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						荣誉证书
					</view>
					<view class="cu-form-group">
						<view class="title">荣誉名称</view>
						<input placeholder="请输入荣誉名称" name="input" v-model="honors.name"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">荣誉证书</view>
						<view class="grid col-4 grid-square flex-sub">
							<view class="bg-img" v-for="(item,index) in honors.localImages" :key="index"
								@tap="ViewImage" :data-url="honors.localImages[index]">
								<image :src="honors.localImages[index]" mode="aspectFill"></image>
								<view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index">
									<text class='cuIcon-close'></text>
								</view>
							</view>
							<view class="solids" @tap="ChooseImageHonorsCopy" v-if="honors.localImages.length<1">
								<text class='cuIcon-cameraadd'></text>
							</view>
						</view>
					</view>

					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg"
							@click="onSubmitData('honors',{name: '',images: [],localImages: []})">提交</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 其他事项 -->
		<view class="cu-modal" :class="modalName=='otherMatters'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						其他事项
					</view>
					<view class="cu-form-group">
						<view class="title">说明</view>
						<input placeholder="请输入说明" name="input" v-model="otherMatters.reason"></input>
					</view>
					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg" @click="onSubmitData('otherMatters')">提交</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 本公司奖惩情况 -->
		<view class="cu-modal" :class="modalName=='ourCompanyReceivesRewards'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop>
				<view class="cu-list menu text-left solid-top">
					<view class="cu-form-group">
						本公司奖惩情况
					</view>
					<view class="cu-form-group">
						<view class="title">离职详情</view>
						<input placeholder="请输入离职详情" name="input"
							v-model="ourCompanyReceivesRewards.leaveReason"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">详情</view>
						<input placeholder="请输入详情" name="input" v-model="ourCompanyReceivesRewards.reason"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">奖惩情况</view>
						<input placeholder="请输入奖惩情况" name="input" v-model="ourCompanyReceivesRewards.rewards"></input>
					</view>
					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue lg" @click="onSubmitData('ourCompanyReceivesRewards')">提交</button>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import myDate from '@/components/my-componets/my-date.vue'
	import mySelect from '@/components/my-componets/my-select.vue'
	export default {
		components: {
			myDate,
			mySelect
		},
		data() {
			return {
				idCardValidPeriod: '2000-01-01',
				idCardStartTime: '2000-01-01',
				birthday: '2000-01-01',
				firstTimeWorking: '2000-01-01',
				graduationTime: '2000-01-01',
				proposedEmploymentDate: '2000-01-01',
				probationPeriodStartTime: '2000-01-01',
				regularDate: '2000-01-01',
				listTouchStart: 0,
				listTouchDirection: null,
				familyMembers: {
					relationship: '',
					name: '',
					phone: '',
					workUnit: ''
				}, //家庭成员
				resumes: {}, //个人简历
				subPosts: {
					departTitle: ''
				}, //附属职务
				honors: {
					name: '',
					images: [],
					localImages: []
				}, //荣誉证书
				otherMatters: {}, //其他事项
				ourCompanyReceivesRewards: {}, //本公司奖惩情况
				startTime: '2000-01-01',
				endTime: '2000-01-01',
				modalName: null,
				index: -1,
				switchC: true,
				imgList: [],
				imgListIdCardCopy: [],
				uploadUrl: "/sys/common/upload",
				departFrom: '',
				myFormData: {
					company: '',
					identityCategory: '',
					avatar: 1,
					realname: 20,
					sex: '',
					idCard: '',
					idCardIssue: '',
					idCardAddress: '',
					idCardValidPeriod: '',
					idCardStartTime: '',
					birthday: '',
					nation: '',
					nativePlace: '',
					email: '',
					phone: '',
					maritalStatus: '',
					height: '',
					partyAndLeagueMembers: '',
					title: '',
					firstTimeWorking: '',
					education: '',
					graduationTime: '',
					graduationInstitution: '',
					currentAddress: '',
					emergencyContact: '',
					emergencyContactPhone: '',
					idCardCopy: '',
					post: '',
					departIds: '',
					departTitle: '',
					relatedJobAllocation: '',
					relatedJobAllocationTxt: '',
					proficiency: '',
					speciality: '',
					proposedEmploymentDate: '',
					probationPeriodStartTime: '',
					probationPeriodDuration: '',
					reportedWithinThreeDays: '',
					probationSalary: '',
					regularSalary: '',
					currentSalary: '',
					accommodationMethods: '',
					workNo: '',
					familyMembers: [],
					resumes: [],
					subPosts: [],
					honors: [],
					otherMatters: [],
					ourCompanyReceivesRewards: []
				},
			};
		},
		onLoad: function(option) {
			console.log("this.$Route.query", this.$Route.query);
			let query = this.$Route.query
			if (query) {
				this.myFormData = query;
				if (this.myFormData.sex == '女') {
					this.switchC = false
				} else if (this.myFormData.sex == '男') {
					this.switchC = true
				}
				if (this.myFormData.avatar) {
					this.imgList = [this.myFormData.avatar]
				}
				if (this.myFormData.idCardCopy) {
					this.imgListIdCardCopy = [this.myFormData.idCardCopy]
				}
				if (!this.myFormData.birthday) {
					this.myFormData.birthday = '无'
				}
				if (this.myFormData.identity == '普通成员') {
					this.myFormData.identity = 1
				} else if (this.myFormData.identity == '上级') {
					this.myFormData.identity = 2
				}
				if (this.myFormData.status == '正常') {
					this.myFormData.status = 1
				} else if (this.myFormData.status == '冻结') {
					this.myFormData.status = 2
				}
				this.Avatar = this.myFormData.avatar
				this.AvatarIdCardCopy = this.myFormData.idCardCopy

				Object.keys(this.myFormData).map(key => {
					if (this.myFormData[key] == '无') {
						this.myFormData[key] = ''
					}
				})
				console.log("this.myFormData==", this.myFormData)
			}

			uni.$on('departCallBack', (data) => {
				if (this.departFrom == 'subPosts') {
					this.$set(this.subPosts, 'departIds', data?.idArray?.join(','))
					this.$set(this.subPosts, 'departTitle', data?.titleArray?.join('>'))
				} else {
					this.$set(this.myFormData, 'departIds', data?.idArray?.join(','))
					this.$set(this.myFormData, 'departTitle', data?.titleArray?.join('>'))
				}
			})
		},
		methods: {
			onSubmit() {
				let myForm = this.myFormData
				let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
				let checkEmail = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
				console.log("myForm", myForm)
				//  if(!myForm.phone || myForm.phone.length==0){
				// this.$tip.alert('请输入手机号');
				// return false
				//  }
				//  if(!checkPhone.test(myForm.phone)){
				// this.$tip.alert('请输入正确的手机号');
				// return false
				//  }
				//  if(!checkEmail.test(myForm.email)){
				// this.$tip.alert('请输入正确的邮箱地址');
				// return false
				//  }
				this.myFormData.id = this.$store.getters.userid
				if (this.switchC) {
					this.myFormData.sex = 1
				} else {
					this.myFormData.sex = 2
				}
				console.log('myform', this.myFormData)
				this.$tip.loading();
				this.$http.post('/crm_employment_application/crmEmploymentApplication/add', this.myFormData)
					.then(res => {
						console.log(res)
						this.$tip.loaded();
						if (res.data.success) {
							this.$tip.toast('提交成功')
							// this.$Router.replace({name:'userdetail'})
							/* uni.navigateTo({
								url: '/pages/user/userdetail'
							}) */
						}
					}).catch(() => {
						this.$tip.loaded();
						this.$tip.error('提交失败')
					});
			},
			DateChangeIdCardValidPeriod(e) {
				this.idCardValidPeriod = e.detail.value
				this.myFormData.idCardValidPeriod = e.detail.value
			},
			DateChangeIdCardStartTime(e) {
				this.idCardStartTime = e.detail.value
				this.myFormData.idCardStartTime = e.detail.value
			},
			DateChangeBirthday(e) {
				this.birthday = e.detail.value
				this.myFormData.birthday = e.detail.value
			},
			DateChangeFirstTimeWorking(e) {
				this.firstTimeWorking = e.detail.value
				this.myFormData.firstTimeWorking = e.detail.value
			},
			DateChangeGraduationTime(e) {
				this.graduationTime = e.detail.value
				this.myFormData.graduationTime = e.detail.value
			},
			DateChangeProposedEmploymentDate(e) {
				this.proposedEmploymentDate = e.detail.value
				this.myFormData.proposedEmploymentDate = e.detail.value
			},
			DateChangeProbationPeriodStartTime(e) {
				this.probationPeriodStartTime = e.detail.value
				this.myFormData.probationPeriodStartTime = e.detail.value
			},
			DateChangeRegularDate(e) {
				this.regularDate = e.detail.value
				this.myFormData.regularDate = e.detail.value
			},
			DateChangeStartTime(e) {
				this.startTime = e.detail.value
				this.myFormData.startTime = e.detail.value
			},
			DateChangeEndTime(e) {
				this.endTime = e.detail.value
				this.myFormData.endTime = e.detail.value
			},

			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			deleteData(index, type) {
				let temp = this.myFormData[type]
				console.log(index, type, temp)
				temp.splice(index, 1);
				this.$set(this.myFormData, type, temp)
			},
			editData(index, type) {
				this.modalName = type
				this[type] = this.myFormData[type][index]
			},
			onSubmitData(type,
				defaultValue = {}) {
				console.log(type, this.myFormData[type], this[type])
				let temp = this.myFormData[type]
				if (temp == undefined) {
					temp = []
				}
				temp.push(this[type])
				this.$set(this.myFormData, type, temp)
				this[type] =
					defaultValue
				this.modalName = null
			},

			// ListTouch触摸开始
			ListTouchStart(e) {
				this.listTouchStart = e.touches[0].pageX
			},
			// ListTouch计算方向
			ListTouchMove(e) {
				this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
			},
			// ListTouch计算滚动
			ListTouchEnd(e) {
				if (this.listTouchDirection == 'left') {
					this.modalName = e.currentTarget.dataset.target
				} else {
					this.modalName = null
				}
				this.listTouchDirection = null
			},
			hideModal(e) {
				this.modalName = null
			},
			SwitchC(e) {
				this.switchC = e.detail.value
			},
			ChooseDepartIds(from = '') {
				this.departFrom = from;
				console.log("==========")
				uni.navigateTo({
					url: '/pages/oa/common/depart',
				});
				// var that=this;
				// uni.chooseImage({
				// 	count: 4, //默认9
				// 	sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				// 	sourceType: ['album'], //从相册选择
				// 	success: (res) => {
				// 		that.$http.upload(that.$config.apiUrl+that.uploadUrl, {
				// 				filePath: res.tempFilePaths[0],
				// 				name: 'file'
				// 			})
				// 			.then(res => {
				// 				that.myFormData.avatar=res.data.message;
				// 			})
				// 			.catch(err => {
				// 				that.$tip.error(err.data.message)
				// 			});
				// 		this.imgList = res.tempFilePaths
				// 	}
				// });
			},
			ChooseImage() {
				var that = this;
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						that.$http.upload(that.$config.apiUrl + that.uploadUrl, {
								filePath: res.tempFilePaths[0],
								name: 'file'
							})
							.then(res => {
								that.myFormData.avatar = res.data.message;
							})
							.catch(err => {
								that.$tip.error(err.data.message)
							});
						this.imgList = res.tempFilePaths
					}
				});
			},
			ChooseImageIdCardCopy() {
				var that = this;
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						that.$http.upload(that.$config.apiUrl + that.uploadUrl, {
								filePath: res.tempFilePaths[0],
								name: 'file'
							})
							.then(res => {
								that.myFormData.idCardCopy = res.data.message;
							})
							.catch(err => {
								that.$tip.error(err.data.message)
							});
						this.imgListIdCardCopy = res.tempFilePaths
						console.log(this.imgListIdCardCopy)
					}
				});
			},
			ChooseImageHonorsCopy() {
				var that = this;
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						that.$http.upload(that.$config.apiUrl + that.uploadUrl, {
								filePath: res.tempFilePaths[0],
								name: 'file'
							})
							.then(res => {
								that.honors.images.push(res.data.message)
							})
							.catch(err => {
								that.$tip.error(err.data.message)
							});
						this.honors.localImages = res.tempFilePaths
					}
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			}
		},
		watch: {
			"myFormData.familyMembers": function(newName, oldName) {
				console.log('familyMembers==', newName, oldName)
			}
		}
	}
</script>

<style scoped>
	.cu-modal {
		z-index: 99;
	}

	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}

	.fontUnify {
		font-size: 14px;
	}

	.page {
		height: 100Vh;
		width: 100vw;
	}

	.page.show {
		overflow: hidden;
	}

	.switch-sex::after {
		content: "\e716";
	}

	.switch-sex::before {
		content: "\e7a9";
	}

	.switch-music::after {
		content: "\e66a";
	}

	.switch-music::before {
		content: "\e6db";
	}

	.cu-form-group+.cu-form-group {
		border: none;
	}

	.cu-list {
		background-color: #ffffff;

	}
</style>